package com.example.orderservice.feign;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

// 声明调用的服务名称（对应库存服务的spring.application.name）
@FeignClient(name = "stock-service")
public interface StockFeignClient {

    // 调用库存服务的扣减接口
    @PostMapping("/stock/deduct")
    boolean deductStock(
            @RequestParam("productId") String productId,
            @RequestParam("quantity") int quantity
    );

    // 调用库存服务的查询接口
    @GetMapping("/stock/query")
    int queryStock(@RequestParam("productId") String productId);
}